#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.57)
AC_INIT(dlib, 1.0, <deanjones@cleancode.org>)
AC_CONFIG_SRCDIR([src/dnet.c])
AC_CONFIG_HEADER([include/config.h])

version="1.0"
cwd=`pwd`

# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET

AC_ARG_WITH(ssl, [  --with-ssl		  force use of TLS/SSL], [use_ssl=$withval], )
AC_SYS_LARGEFILE

if test -n "$GCC"; then
    CFLAGS="$CFLAGS -Wall -W"
fi

# Checks for libraries.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(m, sqrt)
AC_CHECK_LIB(nsl, gethostbyname)
if test -z "$use_ssl" -o "$use_ssl" = "yes"; then
	AC_CHECK_LIB(ssl, SSL_library_init)
	AC_CHECK_LIB(crypto, X509_free)
	AC_CHECK_LIB(crypto, RAND_seed)
fi

echo $LIBS

# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/socket.h sys/time.h termios.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_TIME
AC_STRUCT_TM

# Checks for library functions.
AC_FUNC_FORK
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([gethostbyname gethostname getpass gettimeofday memset putenv socket sqrt strcasecmp strchr strerror strrchr uname])

CFLAGS="$CFLAGS -I$cwd -I$cwd/src -I$cwd/include -I../include "

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
